﻿using SWEN3Application.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace SWEN3Application
{
    public partial class Login : Form
    {
        public Login()
        {
            Thread t = new Thread(new ThreadStart(splashscreen));
            t.Start();
            Thread.Sleep(4782);
            t.Abort();
            InitializeComponent();
            
        }

        public void splashscreen()
        {
            Application.Run(new LoaderForm());
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            GeneralModuleDBManager gm = new GeneralModuleDBManager();
            UserAccount user = new UserAccount();
            user = gm.login(tbxUsername.Text, tbxPassword.Text);
            if (user != null)
            {
                MasterForm mf = new MasterForm();
                mf.Show();
                this.Hide();
            }
            else
            {
                lblStatus.Text = "Acccout Doesn't Exist";
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            tbxUsername.Text = "";
            tbxPassword.Text = "";
        }
    }
}
